//
//  MDHCommonHeaderView.swift
//  JSTech
//
//  Created by 高得华 on 2019/5/13.
//  Copyright © 2020 华&梅. All rights reserved.
//

import UIKit


class MDHCommonHeaderView: MDHTableViewHeaderFooterView {
    ///数据 ViewModel
    @objc var viewModel = MDHCommonGroupViewModel()
    
    required init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        ///初始化
        self.setup()
        // 创建自控制器
        self.setupSubViews()
        // 布局子控件
        self.makeSubViewsConstraints()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func bindViewModel(_ viewModel: Any!) {
        let m = viewModel as? MDHCommonGroupViewModel ?? MDHCommonGroupViewModel()
        self.viewModel = m
        self.contentLabel.text = m.header
    }
    
    ///初始化
    fileprivate func setup() -> () {
        //self.contentView.backgroundColor = kColor_MDHEEEEEE()//UIColor.init(hexString: "#EFEFF4")
    }
    // 创建自控制器
    fileprivate func setupSubViews() -> () {
        self.contentView.addSubview(self.contentLabel)
    }
    // 布局子控件
    fileprivate func makeSubViewsConstraints() -> () {
        self.contentLabel.mas_makeConstraints { (make) in
            make?.left.equalTo()(15)
            make?.top.equalTo()(5)
            make?.center.equalTo()(0)
        }
    }
}
